/*
 * int_module.c
 *
 *  Created on: Mar 8, 2013
 *      Author: George
 */
#include "common.h"
extern uint32 __VECTOR_RAM[];
void set_pit_handler(int vector, void (*handler)(void))
{
	
	__VECTOR_RAM[vector]=(uint32)handler;
	
	// Unmask the 55th slot
	MCF_INTC0_IMRH &= ~(1) << 23;
	//set PIT's (55) interrupt level to 5 and priority to 7
	MCF_INTC0_ICR55 |= (5) << 3;
	MCF_INTC0_ICR55 |= (7);
}


__declspec(interrupt) void pit_handler(void)
{
	
	//write to PIF to clear interrupt flag
	//may need to call a function instead to check what length is next note and write to PMR to set the new counter
	MCF_PIT0_PCSR |= 1 << 2;
	/*OR 
	 * set counter to change the length of next note(or pause)
	 * 
	 */
	//Play the next note in the sequence	
	play_next();
}


void set_gpt_handler(int vector, void (*handler)(void))
{
	
	__VECTOR_RAM[vector]=(uint32)handler;
	
	// Unmask the 55th slot
	MCF_INTC0_IMRH &= ~(1) << 12;
	//set PIT's (55) interrupt level to 5 and priority to 7
	MCF_INTC0_ICR44 |= (5) << 3;
	MCF_INTC0_ICR44 |= (6);
}


__declspec(interrupt) void gpt_handler(void)
{
	
	//write to PIF to clear interrupt flag
	//may need to call a function instead to check what length is next note and write to PMR to set the new counter
	MCF_GPT_GPTFLG1 |= 1;
	/*OR 
	 * set counter to change the length of next note(or pause)
	 * 
	 */
	//Play the next note in the sequence	
	mod_tempo();
	
}

